home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
pascal
/
tvdmx.exe
/
TVGIZMA.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-07-16
|
16KB
|
636 lines
{■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
{ }
{ tvGIZMA --Turbo Vision Accessories }
{ }
{ Copyright (c) 1992 Randolph Beck }
{ P.O. Box 56-0487 }
{ Orlando, FL 32856 }
{ CIS: 72361,753 }
{ }
{■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■}
Unit tvGIZMA;
{$D-,B-,O+,R-,V-,X+ }
interface
uses
Dos, Crt, Objects, Drivers, Memory, Dialogs, Menus,
HistList, Views, App, MsgBox, Buffers, RSet, DmxGizma;
const
cmUserScreen = cmDMX + 51; { invokes User Screen }
cmToggleSound = cmDMX + 52; { toggles BeepOn }
cmToggleVideo = cmDMX + 53; { toggles video mode }
cmBeep = cmDMX + 54; { beeps if BeepOn is TRUE }
BeepOn : boolean = TRUE; { allows beeping from cmBeep event }
SoundIndOn = ' ON'; { On & Off must be the same length }
SoundIndOff = 'OFF';
VideoIndHi = '43/50'; { Hi & Low must be the same length }
VideoIndLow = ' 25';
type
PCursorDlg = ^TCursorDlg;
TCursorDlg = OBJECT (TDialog)
procedure HandleEvent (var Event : TEvent); VIRTUAL;
end;
PTimeView = ^TTimeView;
TTimeView = OBJECT (TView)
Hour,Min : word;
constructor Init (var Bounds : TRect);
procedure Draw; VIRTUAL;
procedure Update; VIRTUAL;
end;
PAppA = ^TAppA;
TAppA = OBJECT (TProgram)
Clock : PTimeView;
SoundInd : pstring;
VideoInd : pstring;
constructor Init;
destructor Done; VIRTUAL;
procedure HandleEvent (var Event : TEvent); VIRTUAL;
procedure Idle; VIRTUAL;
procedure InitClock; VIRTUAL;
function NewSoundItem (AHelpCtx : word; ANext : PMenuItem) : PMenuItem;
function NewVideoItem (AHelpCtx : word; ANext : PMenuItem) : PMenuItem;
procedure OutOfMemory; VIRTUAL;
private
KeptScreen : PVideoBuf;
Col,Row : byte;
end;
PUserScreen = ^TUserScreen;
TUserScreen = OBJECT (TScroller)
constructor Init (var Bounds : TRect; AHScrollBar,AVScrollBar : PScrollBar);
procedure Draw; VIRTUAL;
procedure HandleEvent (var Event : TEvent); VIRTUAL;
function Valid (Command : word) : boolean; VIRTUAL;
end;
function SParam (S : pstring; Next : pointer) : pointer;
function DParam (N : longint; Next : pointer) : pointer;
{ accessories for FormatStr() and MessageBox() procedures }
procedure AssignWinRect (var Bounds : TRect; MaxX,MaxY : integer);
{ assigns a rectangle to cascade into the desktop }
function InsertLine (Dialog : PDialog; Col,Row,Width,Max : integer;
Fmt : boolean; ALabel : string; hlID : word) : PInputLine;
{ inserts a TInputLine view with (optional) history list }
function InsertText (Dialog : PDialog; Col,Row : integer; AText : string) : PView;
{ inserts a single-line standard text view }
function InsertView (Owner :PGroup; View :PView; Options :word) : pointer;
{ sets a view's options and inserts it into an owner }
function NewVarItem (Name, Param : TMenuStr; var Ind : pstring;
KeyCode, Command, AHelpCtx : word;
Next : PMenuItem) : PMenuItem;
{ creates a new menu item with a status indicator }
function NextWindowNumber : integer;
{ finds an unused window number }
procedure TrimDialog (Window : PWindow);
{ resizes a dialog window }
implementation
{ ══ Param Functions ═══════════════════════════════════════════════════ }
const iparmax = 15; { maximum number of parameters - 1 }
ipar : integer = iparmax;
var Apar : array [0..iparmax] of pointer;
function SParam (S : pstring; Next : pointer) : pointer;
begin
{$IFOPT R+ }
If (ipar < 0) then RunError (201);
{$ENDIF }
If (Next = nil) then ipar := iparmax;
Apar [ipar] := S;
SParam := @Apar [ipar];
Dec (ipar);
end;
function DParam (N : longint; Next : pointer) : pointer;
begin
{$IFOPT R+ }
If (ipar < 0) then RunError (201);
{$ENDIF }
If (Next = nil) then ipar := iparmax;
Apar [ipar] := pointer (N);
DParam := @Apar [ipar];
Dec (ipar);
end;
{ ══════════════════════════════════════════════════════════════════════ }
procedure AssignWinRect (var Bounds : TRect; MaxX,MaxY : integer);
var P : PView;
begin
DeskTop^.GetExtent (Bounds);
If (MaxX <= 0) then MaxX := Bounds.B.X;
If (MaxY <= 0) then MaxY := Bounds.B.Y;
If (Bounds.B.X > MaxX) then Bounds.B.X := MaxX;
If (Bounds.B.Y > MaxY) then Bounds.B.Y := MaxY;
P := DeskTop^.Current;
If (P^.Options and ofTileable = 0) then P := nil;
If (P <> nil) then
begin
Bounds.Move (succ (P^.Origin.X), succ (P^.Origin.Y));
If (Bounds.B.X > DeskTop^.Size.X) then Bounds.B.X := DeskTop^.Size.X;
If (Bounds.B.Y > DeskTop^.Size.Y) then Bounds.B.Y := DeskTop^.Size.Y;
If (Bounds.B.X - Bounds.A.X < MinWinSize.X) or
(Bounds.B.Y - Bounds.A.Y < MinWinSize.Y) then
begin
If (MaxX >= DeskTop^.Size.X) then MaxX := pred (DeskTop^.Size.X);
Bounds.A.X := 1;
Bounds.A.Y := 0;
Bounds.B.X := succ (MaxX);
Bounds.B.Y := MaxY;
end;
end;
end;
{ ══════════════════════════════════════════════════════════════════════ }
function InsertLine (Dialog : PDialog; Col,Row,Width,Max : integer;
Fmt : boolean; ALabel : string; hlID : word) : PInputLine;
var i : integer;
R : TRect;
B : PInputLine;
begin
With Dialog^ do
begin
i := succ (CStrLen (ALabel));
R.Assign (Col, Row, Col + Width + 2, succ (Row));
If (ALabel <> '') then
begin
If Fmt then R.Move (1, 1) else R.Move (i, 0);
end;
B := New (PInputLine, Init (R, Max));
Insert (B);
If (hlID > 0) then
begin
R.A.X := R.A.X + Width + 2;
R.B.X := R.A.X + 3;
Insert (New (PHistory, Init (R, B, hlID)));
end;
If (ALabel <> '') then
begin
R.Assign (Col, Row, Col + i, succ (Row));
Insert (New (PLabel, Init (R, ALabel, B)));
end;
end;
InsertLine := B;
end;
{ ══════════════════════════════════════════════════════════════════════ }
function InsertText (Dialog : PDialog; Col,Row : integer; AText : string) : PView;
var R : TRect;
B : PView;
begin
With Dialog^ do
begin
R.Assign (Col, Row, Col + length (AText), succ (Row));
B := New (PStaticText, Init (R, AText));
Insert (B);
end;
InsertText := B;
end;
{ ══════════════════════════════════════════════════════════════════════ }
function InsertView (Owner :PGroup; View :PView; Options :word) : pointer;
begin
If (View <> nil) then
begin
View^.Options := View^.Options or Options;
If (Owner <> nil) then Owner^.Insert (View);
end;
InsertView := View;
end;
{ ══════════════════════════════════════════════════════════════════════ }
function NewVarItem (Name, Param : TMenuStr; var Ind : pstring;
KeyCode, Command, AHelpCtx : word;
Next : PMenuItem) : PMenuItem;
var P : PMenuItem;
begin
P := NewItem (Name,Param, KeyCode,Command,AHelpCtx, Next);
Ind := P^.Param;
NewVarItem := P;
end;
{ ══════════════════════════════════════════════════════════════════════ }
function NextWindowNumber : integer;
var wn : integer;
function UsedWN (P : PWindow) : boolean; far;
begin
UsedWN := (P^.Number = wn) and (P <> PWindow (DeskTop^.Background))
end;
begin
wn := 0;
Repeat Inc (wn) until (DeskTop^.FirstThat (@UsedWN) = nil);
NextWindowNumber := wn;
end;
{ ══════════════════════════════════════════════════════════════════════ }
procedure TrimDialog (Window : PWindow);
var B : TRect;
MinX : integer;
procedure FindBounds (P : PView); far;
begin
If (PFrame (P) <> Window^.Frame) and (P^.GetState (sfVisible)) then
begin
If (P^.Origin.X < MinX) then MinX := P^.Origin.X;
If (P^.Options and ofCenterX <